$(function(){

	bindDict("roletype", "DM_ROLETYPE", null);
	
	var rolecode = getUrlParam('rolecode');
	initForm(rolecode);
	
	initTable(rolecode);
})

function initForm(rolecode){

	var infoUrl = projectPath + "role/getInfo.do";
	
	$.ajax({ 
		url: infoUrl,
		data: {"rolecode": rolecode},
		dataType: "json",
		success: function(data){
			if(data.result == 1){   
				bindFormInfo(data.datas);
			}
      	}
	});
}

function bindFormInfo(data){
	$('[name="rolecode"]').html(data.rolecode);
	$('[name="rolename"]').html(data.rolename);
	$('[name="roletype"]').val(data.roletype);
	$('[name="roltdescribe"]').html(data.roltdescribe);
}



function initTable(rolecode){
	$('#table').bootstrapTable({
		method: 'post',
	    url: basePath() + 'user/rolelist.do',
//	    pagination: true, //分页
	    dataType: "json",
        contentType: "application/json",
//        pageList: [10, 20, 50, 100],  //可供选择的每页的行数（*）
        striped: true,      //是否显示行间隔色
        sidePagination: "server",
        ////查询参数,每次调用是会带上这个参数，可自定义                         
        queryParams:function(params) {
            return {
                	rolecode: rolecode
                };
        },
	    columns: [{  
            field : 'number',  
            title : '序号',  
            align : 'center',
            width : '80px',
            formatter : function(value, row, index) {  
// 		                return index + 1;  
                var page = $('#table').bootstrapTable("getPage");  
                return page.pageSize * (page.pageNumber - 1) + index + 1;  
            }  
        }, {
	        field: 'userid',
	        title: '用户编号'
	    }, {
	        field: 'username',
	        title: '用户名称'
	    }, {
	        field: 'orgname',
	        title: '所属机构'
	    }, {
	        field: 'deptname',
	        title: '所属部门'
	    }]
	});
}